﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartCity.ProcessEngine.Api.Read.Application.Command.Instance;
using SmartCity.ProcessEngine.Api.Read.Dtos;
using SmartCity.ProcessEngine.ErrorCode;

namespace SmartCity.ProcessEngine.Api.Read.Controllers
{
    /// <summary>
    /// 流程实例控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class InstanceController : ControllerBase
    {
        private readonly IMediator mediator;

        public InstanceController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 我的待办分页列表
        /// </summary>
        /// <param name="request">查询条件</param>
        /// <returns>我的待办响应包装</returns>
        [HttpGet]
        public Task<ApiPaging<MyInstanceDTO>> GetMyInstances([FromQuery] GetMyInstanceCommand request)
        {
            return mediator.Send(request);
        }


        /// <summary>
        /// 实例的审批记录列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>

        [HttpGet]
        public Task<ApiResult<List<RecardListDTO>>> GetRecardList([FromQuery] GetRecardListCommand request)
        {

            return mediator.Send(request);
        }
    }
}
